knitr::opts_chunk$set(
message=FALSE, warning=FALSE, paged.print=TRUE, collapse = TRUE, cache = TRUE, comment = "#>"
)
devtools::load_all(".")

Severity of Disturbed Dreams

dreams_d <- read.csv("~/Desktop/Test package/data/Severity of Disturbed Dreams.csv")
head(dreams_d)

# Wide to long
library(tidyr)
dreams_d1 <- gather(dreams_d, Level, Total, Not.severe:Very.severe)

# Grouped to ungrouped
library(vcdExtra)
dreams_d1 <- expand.dft(dreams_d1, freq="Total")
head(dreams_d1)
summary(dreams_d1)

3. Reference models for nominal response

REFERENCE, LOGISTIC, COMPLETE

l_1 <- GLMref(
  response = "Level",
  explanatory_complete = c("intercept", "Age"),
  explanatory_proportional = c("NA"),
  distribution = "logistic",
  reference_category = "Very.severe",
  dataframe = dreams_d1
)
summary.pcglm(l_1)
l_1$deviance
l_1$`Log-likelihood`

REFERENCE, LOGISTIC, PROPORTIONAL

l_2 <- GLMref(
  response = "Level",
  explanatory_complete = c("NA"),
  explanatory_proportional = c("intercept", "Age"),
  distribution = "logistic",
  reference_category = "Very.severe",
  dataframe = dreams_d1
)
summary.pcglm(l_2)
l_2$deviance
l_2$`Log-likelihood`

Same results as previous, note that the order of the categories is not defined in the "order structure", then, by default there is an automatic ascending order, first by numerical and later by alphabetical order.

l_2 <- GLMref(
  response = "Level",
  explanatory_complete = c("NA"),
  explanatory_proportional = c("intercept", "Age"),
  distribution = "logistic",
  reference_category = c("Not.severe", "Severe.1", "Severe.2", "Very.severe"),
  dataframe = dreams_d1
)
summary.pcglm(l_2)
l_2$deviance
l_2$`Log-likelihood`

REFERENCE, CAUCHIT, COMPLETE

l_3 <- GLMref(
  response = "Level",
  explanatory_complete = c("intercept", "Age"),
  explanatory_proportional = c("NA"),
  distribution = "cauchit",
  reference_category = "Very.severe",
  dataframe = dreams_d1
)
summary.pcglm(l_3)
l_3$deviance
l_3$`Log-likelihood`

Then we change the reference category (Severe.2) and estimate again the three reference models:

REFERENCE, LOGISTIC, COMPLETE

l_1prime <- GLMref(
  response = "Level",
  explanatory_complete = c("intercept", "Age"),
  explanatory_proportional = c("NA"),
  distribution = "logistic",
  reference_category = "Severe.2",
  dataframe = dreams_d1
)
summary.pcglm(l_1prime)
l_1prime$deviance
l_1prime$`Log-likelihood`

REFERENCE, LOGISTIC, PROPORTIONAL

l_2prime <- GLMref(
  response = "Level",
  explanatory_complete = c("NA"),
  explanatory_proportional = c("intercept", "Age"),
  distribution = "logistic",
  reference_category = "Severe.2",
  dataframe = dreams_d1
)
summary.pcglm(l_2prime)
l_2prime$deviance
l_2prime$`Log-likelihood`

REFERENCE, CAUCHIT, COMPLETE

l_3prime <- GLMref(
  response = "Level",
  explanatory_complete = c("intercept", "Age"),
  explanatory_proportional = c("NA"),
  distribution = "cauchit",
  reference_category = "Severe.2",
  dataframe = dreams_d1
)
summary.pcglm(l_3prime)
l_3prime$deviance
l_3prime$`Log-likelihood`

The log-likelihoods l_1 and l_1prime are equal (since the canonical model is invariant under all permutations) whereas the log-likelihoods l_2 and l_2prime are different (respectively l_3 and l_3prime).

4. Adjacent models for ordinal response

Equivalence between (adjacent, logistic, complete) and (reference, logistic, complete) models.

REFERENCE, LOGISTIC, COMPLETE

l <- GLMref(
  response = "Level",
  explanatory_complete = c("intercept", "Age"),
  explanatory_proportional = c("NA"),
  distribution = "logistic",
  reference_category = "Severe.2",
  dataframe = dreams_d1
)
summary.pcglm(l)
l$deviance
l$`Log-likelihood`

ADJACENT, LOGISTIC, COMPLETE

lprime <- GLMadj(
  response = "Level",
  explanatory_complete = c("intercept", "Age"),
  explanatory_proportional = c("NA"),
  distribution = "logistic",
  categories_order = c("Not.severe", "Severe.1", "Severe.2", "Very.severe"),
  dataframe = dreams_d1
)
summary.pcglm(lprime)
lprime$deviance
lprime$`Log-likelihood`

Remark that the log-likelihoods l and l_prime are equal but the parameters estimations are different

Invariance under permutations

Property 11: stable under the reverse permutation

ADJACENT, CAUCHY, COMPLETE

estimation_1 <- GLMadj(
  response = "Level",
  explanatory_complete = c("intercept", "Age"),
  explanatory_proportional = c("NA"),
  distribution = "cauchit",
  categories_order = c("Not.severe", "Severe.1", "Severe.2", "Very.severe"),
  dataframe = dreams_d1
)
summary.pcglm(estimation_1)
estimation_1$deviance
estimation_1$`Log-likelihood`

ADJACENT, GOMPERTZ, PROPORTIONAL

estimation_2 <- GLMadj(
  response = "Level",
  explanatory_complete = c("NA"),
  explanatory_proportional = c("intercept", "Age"),
  distribution = "gompertz",
  categories_order = c("Not.severe", "Severe.1", "Severe.2", "Very.severe"),
  dataframe = dreams_d1
)
summary.pcglm(estimation_2)
estimation_2$deviance
estimation_2$`Log-likelihood`

ADJACENT, CAUCHY, COMPLETE (Reverse order)

estimation_1r <- GLMadj(
  response = "Level",
  explanatory_complete = c("intercept", "Age"),
  explanatory_proportional = c("NA"),
  distribution = "cauchit",
  categories_order = c("Very.severe", "Severe.2", "Severe.1", "Not.severe"),
  dataframe = dreams_d1
)
summary.pcglm(estimation_1r)
estimation_1r$deviance
estimation_1r$`Log-likelihood`

ADJACENT, GOMPERTZ, PROPORTIONAL (Reverse order)

estimation_2r <- GLMadj(
  response = "Level",
  explanatory_complete = c("NA"),
  explanatory_proportional = c("intercept", "Age"),
  distribution = "gompertz",
  categories_order = c("Very.severe", "Severe.2", "Severe.1", "Not.severe"),
  dataframe = dreams_d1
)
summary.pcglm(estimation_2r)
estimation_2r$deviance
estimation_2r$`Log-likelihood`

ADJACENT, GUMBEL, PROPORTIONAL (Reverse order)

estimation_3r <- GLMadj(
  response = "Level",
  explanatory_complete = c("NA"),
  explanatory_proportional = c("intercept", "Age"),
  distribution = "gumbel",
  categories_order = c("Very.severe", "Severe.2", "Severe.1", "Not.severe"),
  dataframe = dreams_d1
)
summary.pcglm(estimation_3r)
estimation_3r$deviance
estimation_3r$`Log-likelihood`

Remark that the log-likelihoods l_1 and l_1r are equal since the Cauchy distribution is symmetric whereas the log-likelihoods l_2 and l_2r are different since the Gompertz distribution is not symmetric. Moreover if the Gumbel distribution is used we the reverse order then the log-likelihoods l_2 and l_3r are equal since the Gumbel distribution is the symmetric of the Gompertz distribution. Otherwise, the parameter estimations are reversed.

5. Cumulative models for ordinal response

The equivalence between the (cumulative, Gompertz, proportional) and (sequential, Gompertz, proportional) models has been demonstrated by Läärä and Matthews (1985).

CUMULATIVE, GOMPERTZ, PROPORTIONAL

l_prime <- GLMcum(
  response = "Level",
  explanatory_complete = c("intercept"),
  explanatory_proportional = c("Age"),
  distribution = "gompertz",
  categories_order = c("Not.severe", "Severe.1", "Severe.2", "Very.severe"),
  dataframe = dreams_d1,
  beta_t = c("FALSE"),   beta_init = c(-0.08, 0.95, -0.84, -0.46, -0.18)
)
summary.pcglm(l_prime)
l_prime$deviance
l_prime$`Log-likelihood`

SEQUENTIAL, GOMPERTZ, PROPORTIONAL

l <- GLMseq(
  response = "Level",
  explanatory_complete = c("intercept"),
  explanatory_proportional = c("Age"),
  distribution = "gompertz",
  categories_order = c("Not.severe", "Severe.1", "Severe.2", "Very.severe"),
  dataframe = dreams_d1
)
summary.pcglm(l)
l$deviance
l$`Log-likelihood`

The log-likelihoods l and l_prime are equal.

Reference

The (reference, F , complete) and (reference, F , proportional) models are invariant under the (J − 1)! permutations that fix the reference category (Property 9). But are they still invariant under other permutations? The canonical (reference, logistic, complete) model, being is invariant under all permutations. Non-invariance of models may be shown when F is analytically defined (see chapter 5). This is more complex for normal for Student distributions ... We obtain J!/(J − 1)! = J = 4 plateaus as expected. Each plateau corresponds to a particular reference category with the (J − 1)! = 6 permutations that fix this category.

For the next two plots, degrees of freedom = 0.2 for Student distribution:

l <- GLMref(
        response = "Level",
        explanatory_complete = c("intercept", "Age"),
        explanatory_proportional = c("NA"),
        distribution = "student",
        reference_category = "Very.severe",
        dataframe = dreams_d1,
        freedom_degrees = 0.2)
summary.pcglm(l)
l$deviance
l$`Log-likelihood`

Ordered log-likelihood of models for all permutations - Reference, Complete

Ordered log-likelihood of models for all permutations - Reference, Proportional

Adjacent and cumulative

Let us note that the specific (adjacent, logistic, com- plete) model is invariant under all permutations. For (adjacent, (cauchit, normal), Z), (cumulative, (logistic, normal), complete)* and (cumulative, (logistic, cauchit, normal), proportional) models for all the J! = 24 permutations we obtain J!/2! = 12 plateaus as expected. Each plateau corresponds to a particular permutation and its associated reverse permutation.

Ordered log-likelihood of models for all permutations - Adjacent, Complete

Ordered log-likelihood of models for all permutations - Adjacent, Proportional

Ordered log-likelihood of models for all permutations - Cumulative, Complete

Ordered log-likelihood of models for all permutations - Cumulative, Proportional

Sequential

The (sequential, F , complete) models are invariant under the trans- position of the last two categories when F is symmetric (Property 14). But are they still invariant under other permutations? Next figure investigates the case of (sequential, symmetric F , complete) models for all the J! = 24 permutations cdfs. We obtain J!/2! = 12 plateaus as expected for logistic (normal and cauchit failed at the estimation of certains permutation). Each plateau corresponds to a particular permutation and its associated transposition of the last two categories.

Ordered log-likelihood of models for all permutations - Sequential, Complete

Ordered log-likelihood of models for all permutations - Sequential, Proportional



ylleonv/pack documentation built on June 29, 2020, 10:36 p.m.